<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-paginator.js"></script>
	</head>
	<body>
		<div class="right-sidebar" style="max-width: 1200px;">
			<p class="bg-success" style="line-height: 30px;text-indent: 30px;margin-top: 10px">充值总额：<strong id="tpayNum"></strong></p>
			<p class="bg-info" style="line-height: 30px;text-indent: 30px">购买总额：<strong id="tbuyNum"></strong></p>
			<section class="table-responsive" id="numMonth">
				<table class="table table-bordered">
					<thead>
						<tr >
							<th>时间</th>
							<th>月充值量</th>
							<th>月购买量</th>
						</tr>
					</thead>
					<tbody id="dataList"></tbody>
				</table>
			</section>
		</div>
		<script type="text/javascript">
			$(function(){
				$.ajax({
					type:"post",
					url:"{:U('Admin/Main/monthDateSave')}",
					success:function(data) {
//					    console.log(data);
					   if(data == 'error') {
					       $("#dataList").html("暂时没有任何数据");
					   }else{
							var str = '';
							var datas = Object.keys(data);
							var buyData = '';
							var payData = '';
							var totalPay = 0;
							var totalBuy = 0;
							for(var i=0;i<datas.length;++i) {
							    if(data[datas[i]].total_pay == null) {
							        payData = 0;
								}else{
							        payData = data[datas[i]].total_pay;
								}
                                if(data[datas[i]].total_buy == null) {
                                    buyData = 0;
                                }else{
                                    buyData = data[datas[i]].total_buy;
                                }
                                totalPay += payData/1;
							    totalBuy += buyData/1;
							    str += "<tr><td>"+datas[i]+"</td><td class='paydata'>"+payData+"</td><td class='buydata'>"+buyData+"</td></tr>"
                            }
							$("#dataList").html(str);
							$("#tpayNum").html(totalPay);
							$("#tbuyNum").html(totalBuy);
					   }
					}
				});
			})
		</script>
	</body>
</html>
